package com.huarui.permission.inteceptor;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.StrutsStatics;
import org.ewaf.framework.cookie.CookieManager;

import com.huarui.permission.service.PermissionService;
import com.huarui.user.model.CookieConstants;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class PermissionInterceptor extends AbstractInterceptor {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5890161150833506527L;

	private PermissionService permissionService;

	public PermissionService getPermissionService() {
		return permissionService;
	}

	public void setPermissionService(PermissionService permissionService) {
		this.permissionService = permissionService;
	}

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		HttpServletRequest request = (HttpServletRequest) invocation
				.getInvocationContext().get(StrutsStatics.HTTP_REQUEST);

		CookieManager cookie = new CookieManager(request);

		String logined = cookie.getValue(CookieConstants.COOKIE_PERM,
				CookieConstants.LOGINED);
		
		
		if(logined.compareToIgnoreCase("true")==0){
			String action = invocation.getProxy().getActionName();
			String method = invocation.getProxy().getMethod();
			
			
			
		}


		return null;
	}

}
